package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.SaleList;
import com.atguigu.jxc.service.SaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.ws.Service;
import java.util.Map;

/**
 * @Author: dongdong lau
 * @CreateTime: 2021/7/25 13:05
 * @Description: 销售管理controller层几口
 */
@RestController
@RequestMapping(value = "/saleListGoods")
public class SaleController {

    @Autowired
    private SaleService saleService;

    @RequestMapping("/save")
    public ServiceVO save(@RequestParam String saleNumber,
                        SaleList saleList,
                        String saleListGoodsStr){
        // 将销售单号存入saleList
        saleList.setSaleNumber(saleNumber);
        // 调用新增销售出库表
        ServiceVO serviceVO = saleService.save(saleList, saleListGoodsStr);
        // 返回结果
        return serviceVO;
    }

    @RequestMapping("/list")
    public Map<String, Object> getSaleList(String saleNumber,
                                           Integer customerId,
                                           Integer state,
                                           String sTime,
                                           String eTime){
        // 调用方法获取数据
        Map<String, Object> saleList = saleService.getSaleList(saleNumber, customerId, state, sTime, eTime);
        // 返回数据
        return saleList;
    }


}
